#include "UIVideoPlayer.h"

bool cocos2d::ui::VideoPlayer::init()
{
	return Widget::init();
}
void cocos2d::ui::VideoPlayer::setFileName(const std::string& videoPath)
{
	_videoURL = videoPath;
}

void cocos2d::ui::VideoPlayer::setURL(const std::string& videoURL)
{
	_videoURL = videoURL;
}

void cocos2d::ui::VideoPlayer::setLooping(bool looping)
{

}

void cocos2d::ui::VideoPlayer::setUserInputEnabled(bool enableInput)
{
	_isUserInputEnabled = enableInput;
}

void cocos2d::ui::VideoPlayer::setStyle(VideoPlayerStyleType style)
{
	_styleType = style;
}

void cocos2d::ui::VideoPlayer::play()
{

}

void cocos2d::ui::VideoPlayer::pause()
{

}

void cocos2d::ui::VideoPlayer::resume()
{

}

void cocos2d::ui::VideoPlayer::stop()
{

}

void cocos2d::ui::VideoPlayer::restart()
{

}

void cocos2d::ui::VideoPlayer::seekTo(float sec)
{

}

bool cocos2d::ui::VideoPlayer::isPlaying() const
{
	return _isPlaying;
}

bool cocos2d::ui::VideoPlayer::isLooping() const
{
	return _isLooping;
}

bool cocos2d::ui::VideoPlayer::isUserInputEnabled() const
{
	return _isUserInputEnabled;
}

void cocos2d::ui::VideoPlayer::setKeepAspectRatioEnabled(bool enable)
{
	_keepAspectRatioEnabled = enable;
}

void cocos2d::ui::VideoPlayer::setFullScreenEnabled(bool fullscreen)
{
	_fullScreenEnabled = fullscreen;
}

bool cocos2d::ui::VideoPlayer::isFullScreenEnabled() const
{
	return _fullScreenEnabled;
}

void cocos2d::ui::VideoPlayer::addEventListenerVideoPlayer(CCObject* target, SEL_VideoPlayerEvent selecter)
{
	_videoPlayerEventListener = target;
	_eventSelecter = selecter;
}

void cocos2d::ui::VideoPlayer::onPlayEvent(int event)
{
	if (_videoPlayerEventListener && _eventSelecter)
	{
		(_videoPlayerEventListener->*_eventSelecter)(this, VideoPlayerEventType(event));
	}
}

void cocos2d::ui::VideoPlayer::setVisible(bool visible)
{
	ui::Widget::setVisible(visible);
}

void cocos2d::ui::VideoPlayer::updateRect(float delta)
{

}

void cocos2d::ui::VideoPlayer::onEnter()
{
	ui::Widget::onEnter();
}

void cocos2d::ui::VideoPlayer::onExit()
{
	ui::Widget::onExit();
}

cocos2d::ui::Widget* cocos2d::ui::VideoPlayer::createCloneInstance()
{
	return VideoPlayer::create();
}

void cocos2d::ui::VideoPlayer::copySpecialProperties(Widget* model)
{
	VideoPlayer* player = dynamic_cast<VideoPlayer*>(model);
	if (player)
	{
		ui::Widget::copySpecialProperties(model);
	}
}

cocos2d::ui::VideoPlayer::VideoPlayer()
{
	_isPlaying = false;
	_isLooping = false;
	_isUserInputEnabled = true;
	_fullScreenDirty = false;
	_fullScreenEnabled = false;
	_keepAspectRatioEnabled = false;

	_styleType = vpst_NONE;

	_videoSource = vps_FILENAME;

	_videoPlayerIndex = -1;
	_videoPlayerEventListener = NULL;
	_eventSelecter = NULL;

	_videoView = NULL;
}

cocos2d::ui::VideoPlayer::~VideoPlayer()
{

}
